﻿var winState = "0";

Ext.onReady(function () {
    yeardata = new Ext.data.JsonStore({
        url: Ext.getClassUrl('RecyclingView', 'GetYearTime'),
        root: 'ResponseObject',
        fields: ['yearid', 'yeartext'],
        listeners: {
            beforeload: function (st, op) {
                var re = new JsonRequest();
                re.category = CATEGORY.READONLY;
                st.baseParams = re;
                st.proxy.conn.jsonData = re;
            }
        }
    });
    yeardata.load();
    //数据列表
    var lmsstore = new Ext.data.JsonStore({
        url: Ext.getClassUrl('SecurityMarket.EverydayRisksView', 'GetHazardTypes'),
        root: 'ResponseObject',
        fields: ['隐患类别', '合计'],
        listeners: {
            beforeload: function (st, op) {
                var re = new JsonRequest();
                re.category = CATEGORY.READONLY;
                re.params.year = Ext.getCmp("year").getValue();
                re.params.month = Ext.getCmp("month").getValue();
                st.baseParams = re;
                st.proxy.conn.jsonData = re;
            }
        }
    });


    var lmsdatagrid = new Ext.grid.GridPanel({
        autoscroll: true,
        bodyStyle: 'padding:2px',
        border: false,
        loadMask: true, //加载
        columns: [
           { id: '隐患类别', header: '隐患类别', width: 100, dataIndex: '隐患类别', sortable: true },
           { header: '合计', width: 100, dataIndex: '合计', sortable: true }
   ],
        store: lmsstore
    });
    //布局
    new Ext.Viewport({
        layout: 'border',
        items: [{
            region: 'center',
            layout: 'border',
            border: false,
            title: '团柏矿安全市场→隐患类别',
            iconCls: 'ReportTitle-icon',
            tbar: ['日期：', { xtype: 'combo', width: 100, id: 'year',
                typeAhead: true,
                triggerAction: 'all',
                lazyRender: true,
                mode: 'local',
                store: yeardata,
                valueField: 'yearid',
                displayField: 'yeartext'
            }, '年', { xtype: 'combo', width: 70, id: 'month',
                typeAhead: true,
                triggerAction: 'all',
                lazyRender: true,
                mode: 'local',
                store: new Ext.data.ArrayStore({
                    id: 0,
                    fields: [
                            'monthid',
                            'monthtext'
                        ],
                    data: [['01', '01'], ['02', '02'], ['03', '03'], ['04', '04'], ['05', '05'], ['06', '06'], ['07', '07'], ['08', '08'], ['09', '09'], ['10', '10'], ['11', '11'], ['12', '12']]
                }),
                valueField: 'monthid',
                displayField: 'monthtext'
            }, '月', { xtype: 'button', text: '查询', iconCls: 'search-icon', handler: function () {
                lmsstore.removeAll();
                lmsstore.load();
                }
            },'->', { xtype: 'button', text: '返回', height: 20, width: 50, iconCls: 'page-back-icon', handler: function () {
                window.history.back(-1);
                }
            }],
            items: [{
                region: 'west',
                title: '数据报表',
                iconCls: 'DataList-icon',
                style: 'padding:2px',
                collapsible: false,
                width: 300,
                split: false,
                id: 'DataList',
                layout: 'fit',
                items: lmsdatagrid
            }, {
                region: 'center',
                border: false,
                split: true,
                iconCls: 'ImgDataList-icon',
                id: 'ImgDataList',
                style: 'padding-top:2px;padding-right:2px;padding-bottom:2px',
                title: '隐患类别',
                items: [{
                    xtype: 'columnchart',
                    store: lmsstore,
                    chartStyle: {
                        padding: 10,
                        animationEnabled: true,
                        font: {
                            name: 'Tahoma',
                            color: 0x444444,
                            size: 11
                        },
                        dataTip: {
                            padding: 5,
                            border: {
                                color: 0x99bbe8,
                                size: 1
                            },
                            background: {
                                color: 0xDAE7F6,
                                alpha: .9
                            }
                        },
                        xAxis: {
                            color: 0x69aBc8,
                            majorTicks: { color: 0x69aBc8, length: 4 },
                            minorTicks: { color: 0x69aBc8, length: 2 },
                            majorGridLines: { size: 1, color: 0xeeeeee },
                            labelRotation: -90
                        },
                        yAxis: {
                            zeroGridLine:
	                            {
	                                size: 2,
	                                color: 0xff0000
	                            },
                            color: 0x69aBc8,
                            majorTicks: { color: 0x69aBc8, length: 4 },
                            minorTicks: { color: 0x69aBc8, length: 2 },
                            majorGridLines: { size: 1, color: 0xdfe8f6 }
                        }
                    },
                    xField: '隐患类别',
                    yField: '合计',
                    yAxis: new Ext.chart.NumericAxis({
                        displayName: '合计',
                        labelRenderer: Ext.util.Format.numberRenderer('0,0')
                    }),
                    series: [{
                        type: 'column',
                        displayName: '合计',
                        yField: '合计'
                    }]

                }]
            }],
            listeners: {
                render: function () {
                    Ext.getCmp("year").setValue(YearT);
                    Ext.getCmp("month").setValue(MonthT);
                    lmsstore.load();
                }
            }
        }]
    })
});


